unit basicio_city;

{$mode delphi}{$H+}

{
  stores all information about a city
}

interface

uses
  Classes, SysUtils, fgl, basicio_player;

type

   { TCityPosition }

   TCityPosition = record
     x,y: integer;
     class operator Equal (a,b: TCityPosition)B: Boolean;
   end;

  { TCity }
  TCity = class
    private
      FPos: TCityPosition;
      FOwner: TPlayer;
      FExtended: boolean;
      function GetX: integer;
      function GetY: integer;
    public
      constructor Create(APos: TCityPosition; AOwner: TPlayer);
      destructor Destroy; override;
    public
      property X: integer read GetX;
      property Y: integer read GetY;
      property Position: TCityPosition read FPos;
      property Owner: TPlayer read FOwner;
      property isExtended: boolean read FExtended write FExtended;
  end;

  TCityList   = TFPGObjectList<TCity>;


function CityPositionToString(APos: TCityPosition): string;

implementation

function CityPositionToString(APos: TCityPosition): string;
begin
  result := 'x:'+Inttostr(APos.x)+' y:'+inttostr(APos.Y);
end;

{ TCityPosition }

class operator TCityPosition.Equal(a, b: TCityPosition)B: Boolean;
begin
  result := (a.x=b.x) and (a.y=b.y);
end;

{ TCity }

function TCity.GetX: integer;
begin
  result := FPos.x;
end;

function TCity.GetY: integer;
begin
  result := FPos.y;
end;

constructor TCity.Create(APos: TCityPosition; AOwner: TPlayer);
begin
  inherited Create;
  FPos := APos;
  FOwner  := AOwner;
  FExtended := false;
end;

destructor TCity.Destroy;
begin
  inherited Destroy;
end;

end.

